import openai

openai.api_key = "a2e813adf0e145abade3818ece05e69b.2sqR2YsDpDLL5fLp"
openai.api_base = "https://open.bigmodel.cn/api/paas/v4/"

completion = openai.ChatCompletion.create(
    model="glm-4.6",
    messages=[
        {"role": "system", "content": "你是一个聪明且富有创造力的小说作家"},
        {"role": "user", "content": "请你作为童话故事大王，写一篇短篇童话故事"}
    ],
    top_p=0.7,
    temperature=0.9
)

print(completion.choices[0].message['content'])
